package com.ruoyi.approve.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.approve.domain.AssetGzyss;
import com.ruoyi.approve.service.IAssetGzyssService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资产购置验收Controller
 *
 * @author ruoyi
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/gzyss/gzyss")
public class AssetGzyssController extends BaseController
{
    @Autowired
    private IAssetGzyssService assetGzyssService;

    /**
     * 查询资产购置验收列表
     */
    @PreAuthorize("@ss.hasPermi('gzyss:gzyss:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssetGzyss assetGzyss)
    {
        startPage();
        List<AssetGzyss> list = assetGzyssService.selectAssetGzyssList(assetGzyss);
        return getDataTable(list);
    }

    /**
     * 导出资产购置验收列表
     */
    @PreAuthorize("@ss.hasPermi('gzyss:gzyss:export')")
    @Log(title = "资产购置验收", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssetGzyss assetGzyss)
    {
        List<AssetGzyss> list = assetGzyssService.selectAssetGzyssList(assetGzyss);
        ExcelUtil<AssetGzyss> util = new ExcelUtil<AssetGzyss>(AssetGzyss.class);
        util.exportExcel(response, list, "资产购置验收数据");
    }




//    @PreAuthorize("@ss.hasPermi('gzyss:gzyss:remove')")
//    @Log(title = "打回审批预算", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{mid}")
//    public AjaxResult handleNo(@PathVariable("mid") Long[] mid)
//    {
//        System.out.println("审批失败");
//        return toAjax(assetGzyssService.handleNo(mid));
//    }
//    /**
//     * 打回审批预算
//     */
//    @PreAuthorize("@ss.hasPermi('gzyss:gzyss:remove')")
//    @Log(title = "打回审批预算", businessType = BusinessType.UPDATE)
//    @PutMapping("/{lid}")
//    public AjaxResult handleYes(@PathVariable("lid") Long[] lid)
//    {
//        System.out.println("yid"+lid.getClass().getName());
//        System.out.println("审批成功");
//        return toAjax(assetGzyssService.handleYes(lid));
//    }

    @PreAuthorize("@ss.hasPermi('gzyss:gzyss:remove')")
    @Log(title = "打回审批预算", businessType = BusinessType.DELETE)
    @DeleteMapping("/handleNo/{mid}")
    public AjaxResult handleNo(@PathVariable("mid") Long[] mid) {
        System.out.println("审批失败");
        return toAjax(assetGzyssService.handleNo(mid));
    }

    /**
     * 打回审批预算
     */
    @PreAuthorize("@ss.hasPermi('gzyss:gzyss:remove')")
    @Log(title = "打回审批预算", businessType = BusinessType.UPDATE)
    @PutMapping("/handleYes/{lid}")
    public AjaxResult handleYes(@PathVariable("lid") Long[] lid) {
        System.out.println("yid" + lid.getClass().getName());
        System.out.println("审批成功");
        return toAjax(assetGzyssService.handleYes(lid));
    }

}
